package com.superm.service.impl;

import com.superm.entity.Brand;
import com.superm.mappers.BrandMapper;
import com.superm.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BrandServiceImpl implements BrandService {
    @Autowired
    private BrandMapper brandMapper;
    @Override
    public List<Brand> allBrand() {
        return brandMapper.allBrand();
    }
    @Autowired
    private BrandMapper brandMp;
    /**
     * 实现模糊查询品牌
     * @param brand
     * @return
     */
    @Override
    public List<Brand> selectLikeBrand(Brand brand,Integer pageNo,Integer pageSize) {
        if (brand!=null && pageNo!=null && pageSize!=null){
            return brandMp.selectAll(brand,(pageNo-1)*pageSize,pageSize);
        }else {
            return brandMp.selectAll(null,null,null);
        }
    }
    /**
     * 实现根据编号查询品牌信息
     * @param brandId
     * @return
     */
    @Override
    public Brand selectIdBrand(Integer brandId){
        return brandMp.selectIdInfoMation(brandId);
    }

    /**
     * 实现查询总条数
     * @param brand
     * @return
     */
    @Override
    public int selectBrandCount(Brand brand) {
        return brandMp.selectCount(brand);
    }

    /**
     * 实现修改品牌信息
     * @param brand
     * @return
     */
    @Override
    public int updateBrand(Brand brand){
        return brandMp.updateInfoMation(brand);
    }

    /**
     * 实现添加品牌
     * @param brand
     * @return
     */
    @Override
    public int addBrand(Brand brand) {
        return brandMp.addInfoMation(brand);
    }

    /**
     *实现删除品牌信息
     * @param brandId
     * @return
     */
    @Override
    public int deleteBrand(Integer brandId){
        return brandMp.deleteInfoMation(brandId);
    }
}
